package indzcraft.calc;

import java.util.ArrayList;
import java.util.HashMap;

public class GearBuffs {
	
	private HashMap<String,Integer> gearbuffs = new HashMap<String,Integer>();

	public GearBuffs() { }
	
	public GearBuffs(String[] buffs){
		
		for (String item: buffs) {
			//System.out.println(item);
			setBuff(item);
		}
	}
	
	public int get(String buff){
		if(gearbuffs.containsKey(buff)){
			int value = gearbuffs.get(buff);
			return value;
		}
		return 0;
	}
	
	public void setBuff(String buff) {
		if(buff == null) System.out.println("NULL ERROR");
		if(!gearbuffs.containsKey(buff)){
			gearbuffs.put(buff, 1);
		}
	}
	
	public void toggleBuff(String buff) {
		//System.out.println("---");
		//System.out.println(buff);
		if(!gearbuffs.containsKey(buff)){
			//System.out.println("not in, set to 1");
			gearbuffs.put(buff, 1);
		}
		else{
			//System.out.println("in, set to 0");
			gearbuffs.put(buff, 0);
		}
		//System.out.println("---");
	}
	
	public void showBuffs(){
		for (String name: gearbuffs.keySet()) {
			System.out.println(name + " " + gearbuffs.get(name));
		}
	}
	
	public String[] getGearBuffs(){
		ArrayList<String> al = new ArrayList<String>();
		int i = 0;
		for (String name: gearbuffs.keySet()) {
			//if(gearbuffs.get(name) != 0)
				al.add(name);
				i++;
		}
		String[] ret = new String[i];
		al.toArray(ret);
		return ret;
	}
	
	public void setGearBuffs(HashMap<String,Integer> gb){
		this.gearbuffs = gb;
	}
}
